<?php
define("EW_PAGE_ID", "list", TRUE); // Page ID
define("EW_TABLE_NAME", 'view_register_master', TRUE);
?>
<?php 
session_start(); // Initialize session data
ob_start(); // Turn on output buffering
?>
<?php include "ewcfg50.php" ?>
<?php include "ewmysql50.php" ?>
<?php include "phpfn50.php" ?>
<?php include "view_register_masterinfo.php" ?>
<?php include "userfn50.php" ?>
<?php include "tb_usersinfo.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1 
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php

// Open connection to the database
$conn = ew_Connect();
?>
<?php
$Security = new cAdvancedSecurity();
?>
<?php
if (!$Security->IsLoggedIn()) $Security->AutoLogin();
if (!$Security->IsLoggedIn()) {
	$Security->SaveLastUrl();
	Page_Terminate("login.php");
}
?>
<?php

// Common page loading event (in userfn*.php)
Page_Loading();
?>
<?php

// Page load event, used in current page
Page_Load();
?>
<?php
$view_register_master->Export = @$_GET["export"]; // Get export parameter
$sExport = $view_register_master->Export; // Get export parameter, used in header
$sExportFile = $view_register_master->TableVar; // Get export file, used in header
?>
<?php
if ($view_register_master->Export == "excel") {
	header('Content-Type: application/vnd.ms-excel');
	header('Content-Disposition: attachment; filename=' . $sExportFile .'.xls');
}
if ($view_register_master->Export == "csv") {
	header('Content-Type: application/csv');
	header('Content-Disposition: attachment; filename=' . $sExportFile .'.csv');
}
?>
<?php

// Paging variables
$nStartRec = 0; // Start record index
$nStopRec = 0; // Stop record index
$nTotalRecs = 0; // Total number of records
$nDisplayRecs = 20;
$nRecRange = 10;
$nRecCount = 0; // Record count

// Search filters
$sSrchAdvanced = ""; // Advanced search filter
$sSrchBasic = ""; // Basic search filter
$sSrchWhere = ""; // Search where clause
$sFilter = "";

// Master/Detail
$sDbMasterFilter = ""; // Master filter
$sDbDetailFilter = ""; // Detail filter
$sSqlMaster = ""; // Sql for master record

// Set up records per page dynamically
SetUpDisplayRecs();

// Handle reset command
ResetCmd();

// Get basic search criteria
$sSrchBasic = BasicSearchWhere();

// Build search criteria
if ($sSrchAdvanced <> "") {
	if ($sSrchWhere <> "") $sSrchWhere .= " AND ";
	$sSrchWhere .= "(" . $sSrchAdvanced . ")";
}
if ($sSrchBasic <> "") {
	if ($sSrchWhere <> "") $sSrchWhere .= " AND ";
	$sSrchWhere .= "(" . $sSrchBasic . ")";
}

// Save search criteria
if ($sSrchWhere <> "") {
	if ($sSrchBasic == "") ResetBasicSearchParms();
	$view_register_master->setSearchWhere($sSrchWhere); // Save to Session
	$nStartRec = 1; // Reset start record counter
	$view_register_master->setStartRecordNumber($nStartRec);
} else {
	RestoreSearchParms();
}

// Build filter
$sFilter = "";
if ($sDbDetailFilter <> "") {
	if ($sFilter <> "") $sFilter .= " AND ";
	$sFilter .= "(" . $sDbDetailFilter . ")";
}
if ($sSrchWhere <> "") {
	if ($sFilter <> "") $sFilter .= " AND ";
	$sFilter .= "(" . $sSrchWhere . ")";
}

// Set up filter in Session
$view_register_master->setSessionWhere($sFilter);
$view_register_master->CurrentFilter = "";

// Set Up Sorting Order
SetUpSortOrder();

// Export data only
if ($view_register_master->Export == "xml" || $view_register_master->Export == "csv") {
	ExportData();
	Page_Terminate(); // Terminate response
}

// Set Return Url
$view_register_master->setReturnUrl("view_register_masterlist.php");
?>
<?php include "header.php" ?>
<?php if ($view_register_master->Export == "") { ?>
<script type="text/javascript">
<!--
var EW_PAGE_ID = "list"; // Page id

//-->
</script>
<script type="text/javascript">
<!--
var firstrowoffset = 1; // First data row start at
var lastrowoffset = 0; // Last data row end at
var EW_LIST_TABLE_NAME = 'ewlistmain'; // Table name for list page
var rowclass = 'ewTableRow'; // Row class
var rowaltclass = 'ewTableAltRow'; // Row alternate class
var rowmoverclass = 'ewTableHighlightRow'; // Row mouse over class
var rowselectedclass = 'ewTableSelectRow'; // Row selected class
var roweditclass = 'ewTableEditRow'; // Row edit class

//-->
</script>
<script type="text/javascript">
<!--
var ew_DHTMLEditors = [];

//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--

// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js"); 
//-->

</script>
<?php } ?>
<?php if ($view_register_master->Export == "") { ?>
<?php } ?>
<?php

// Load recordset
$bExportAll = (defined("EW_EXPORT_ALL") && $view_register_master->Export <> "");
$bSelectLimit = ($view_register_master->Export == "" && $view_register_master->SelectLimit);
if (!$bSelectLimit) $rs = LoadRecordset();
$nTotalRecs = ($bSelectLimit) ? $view_register_master->SelectRecordCount() : $rs->RecordCount();
$nStartRec = 1;
if ($nDisplayRecs <= 0) $nDisplayRecs = $nTotalRecs; // Display all records
if (!$bExportAll) SetUpStartRec(); // Set up start record position
if ($bSelectLimit) $rs = LoadRecordset($nStartRec-1, $nDisplayRecs);
?>
<p><span class="phpmaker" style="white-space: nowrap;">View: Register Master
<?php if ($view_register_master->Export == "") { ?>
&nbsp;&nbsp;<a href="view_register_masterlist.php?export=excel">Export to Excel</a>
&nbsp;&nbsp;<a href="view_register_masterlist.php?export=csv">Export to CSV</a>
<?php } ?>
</span></p>
<?php if ($view_register_master->Export == "") { ?>
<?php if ($Security->IsLoggedIn()) { ?>
<form name="fview_register_masterlistsrch" id="fview_register_masterlistsrch" action="view_register_masterlist.php" >
<table class="ewBasicSearch">
	<tr>
		<td><span class="phpmaker">
			<input type="text" name="<?php echo EW_TABLE_BASIC_SEARCH ?>" id="<?php echo EW_TABLE_BASIC_SEARCH ?>" size="20" value="<?php echo $view_register_master->getBasicSearchKeyword() ?>">
			<input type="Submit" name="Submit" id="Submit" value="Search (*)">&nbsp;
			<a href="view_register_masterlist.php?cmd=reset">Show all</a>&nbsp;
		</span></td>
	</tr>
	<tr>
	<td><span class="phpmaker"><input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value="" <?php if ($view_register_master->getBasicSearchType() == "") { ?>checked<?php } ?>>Exact phrase&nbsp;&nbsp;<input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value="AND" <?php if ($view_register_master->getBasicSearchType() == "AND") { ?>checked<?php } ?>>All words&nbsp;&nbsp;<input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value="OR" <?php if ($view_register_master->getBasicSearchType() == "OR") { ?>checked<?php } ?>>Any word</span></td>
	</tr>
</table>
</form>
<?php } ?>
<?php } ?>
<?php
if (@$_SESSION[EW_SESSION_MESSAGE] <> "") {
?>
<p><span class="ewmsg"><?php echo $_SESSION[EW_SESSION_MESSAGE] ?></span></p>
<?php
	$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message
}
?>
<form method="post" name="fview_register_masterlist" id="fview_register_masterlist">
<?php if ($view_register_master->Export == "") { ?>
<table>
	<tr><td><span class="phpmaker">
	</span></td></tr>
</table>
<?php } ?>
<?php if ($nTotalRecs > 0) { ?>
<table id="ewlistmain" class="ewTable">
<?php
	$OptionCnt = 0;
?>
	<!-- Table header -->
	<tr class="ewTableHeader">
		<td valign="top" style="white-space: nowrap;">
<?php if ($view_register_master->Export <> "") { ?>
Month Year
<?php } else { ?>
	<a href="view_register_masterlist.php?order=<?php echo urlencode('MonthYear') ?>&ordertype=<?php echo $view_register_master->MonthYear->ReverseSort() ?>">Month Year&nbsp;(*)<?php if ($view_register_master->MonthYear->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_register_master->MonthYear->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top">
<?php if ($view_register_master->Export <> "") { ?>
ID
<?php } else { ?>
	<a href="view_register_masterlist.php?order=<?php echo urlencode('ID') ?>&ordertype=<?php echo $view_register_master->ID->ReverseSort() ?>">ID<?php if ($view_register_master->ID->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_register_master->ID->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top">
<?php if ($view_register_master->Export <> "") { ?>
Prev ID
<?php } else { ?>
	<a href="view_register_masterlist.php?order=<?php echo urlencode('PreviousID') ?>&ordertype=<?php echo $view_register_master->PreviousID->ReverseSort() ?>">Prev ID<?php if ($view_register_master->PreviousID->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_register_master->PreviousID->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top">
<?php if ($view_register_master->Export <> "") { ?>
Log Date
<?php } else { ?>
	<a href="view_register_masterlist.php?order=<?php echo urlencode('LogDate') ?>&ordertype=<?php echo $view_register_master->LogDate->ReverseSort() ?>">Log Date<?php if ($view_register_master->LogDate->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_register_master->LogDate->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top">
<?php if ($view_register_master->Export <> "") { ?>
Prev Log Date
<?php } else { ?>
	<a href="view_register_masterlist.php?order=<?php echo urlencode('PrevLogDate') ?>&ordertype=<?php echo $view_register_master->PrevLogDate->ReverseSort() ?>">Prev Log Date<?php if ($view_register_master->PrevLogDate->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_register_master->PrevLogDate->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top" style="white-space: nowrap;">
<?php if ($view_register_master->Export <> "") { ?>
Link
<?php } else { ?>
	<a href="view_register_masterlist.php?order=<?php echo urlencode('Link') ?>&ordertype=<?php echo $view_register_master->Link->ReverseSort() ?>">Link&nbsp;(*)<?php if ($view_register_master->Link->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_register_master->Link->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top">
<?php if ($view_register_master->Export <> "") { ?>
XReading
<?php } else { ?>
	<a href="view_register_masterlist.php?order=<?php echo urlencode('XReading') ?>&ordertype=<?php echo $view_register_master->XReading->ReverseSort() ?>">XReading<?php if ($view_register_master->XReading->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_register_master->XReading->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top">
<?php if ($view_register_master->Export <> "") { ?>
Prev XReading
<?php } else { ?>
	<a href="view_register_masterlist.php?order=<?php echo urlencode('YesterdayXReading') ?>&ordertype=<?php echo $view_register_master->YesterdayXReading->ReverseSort() ?>">Prev XReading<?php if ($view_register_master->YesterdayXReading->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_register_master->YesterdayXReading->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top">
<?php if ($view_register_master->Export <> "") { ?>
Diff Xreading
<?php } else { ?>
	<a href="view_register_masterlist.php?order=<?php echo urlencode('DiffXreading') ?>&ordertype=<?php echo $view_register_master->DiffXreading->ReverseSort() ?>">Diff Xreading<?php if ($view_register_master->DiffXreading->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_register_master->DiffXreading->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top">
<?php if ($view_register_master->Export <> "") { ?>
Check Amt
<?php } else { ?>
	<a href="view_register_masterlist.php?order=<?php echo urlencode('CheckAmount') ?>&ordertype=<?php echo $view_register_master->CheckAmount->ReverseSort() ?>">Check Amt<?php if ($view_register_master->CheckAmount->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_register_master->CheckAmount->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top">
<?php if ($view_register_master->Export <> "") { ?>
Lunch Amt
<?php } else { ?>
	<a href="view_register_masterlist.php?order=<?php echo urlencode('LunchAmount') ?>&ordertype=<?php echo $view_register_master->LunchAmount->ReverseSort() ?>">Lunch Amt<?php if ($view_register_master->LunchAmount->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_register_master->LunchAmount->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top">
<?php if ($view_register_master->Export <> "") { ?>
Over Amt
<?php } else { ?>
	<a href="view_register_masterlist.php?order=<?php echo urlencode('OverAmount') ?>&ordertype=<?php echo $view_register_master->OverAmount->ReverseSort() ?>">Over Amt<?php if ($view_register_master->OverAmount->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_register_master->OverAmount->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top">
<?php if ($view_register_master->Export <> "") { ?>
Credit Amt
<?php } else { ?>
	<a href="view_register_masterlist.php?order=<?php echo urlencode('CreditAmount') ?>&ordertype=<?php echo $view_register_master->CreditAmount->ReverseSort() ?>">Credit Amt&nbsp;(*)<?php if ($view_register_master->CreditAmount->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_register_master->CreditAmount->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top">
<?php if ($view_register_master->Export <> "") { ?>
Payout Amt
<?php } else { ?>
	<a href="view_register_masterlist.php?order=<?php echo urlencode('PayoutAmount') ?>&ordertype=<?php echo $view_register_master->PayoutAmount->ReverseSort() ?>">Payout Amt&nbsp;(*)<?php if ($view_register_master->PayoutAmount->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_register_master->PayoutAmount->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top">
<?php if ($view_register_master->Export <> "") { ?>
Total Draw Amt
<?php } else { ?>
	<a href="view_register_masterlist.php?order=<?php echo urlencode('TotalDrawAmount') ?>&ordertype=<?php echo $view_register_master->TotalDrawAmount->ReverseSort() ?>">Total Draw Amt&nbsp;(*)<?php if ($view_register_master->TotalDrawAmount->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_register_master->TotalDrawAmount->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top">
<?php if ($view_register_master->Export <> "") { ?>
Prev Draw Amt
<?php } else { ?>
	<a href="view_register_masterlist.php?order=<?php echo urlencode('PreviousDrawAmount') ?>&ordertype=<?php echo $view_register_master->PreviousDrawAmount->ReverseSort() ?>">Prev Draw Amt<?php if ($view_register_master->PreviousDrawAmount->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_register_master->PreviousDrawAmount->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top">
<?php if ($view_register_master->Export <> "") { ?>
Cash Diff
<?php } else { ?>
	<a href="view_register_masterlist.php?order=<?php echo urlencode('CashDiff') ?>&ordertype=<?php echo $view_register_master->CashDiff->ReverseSort() ?>">Cash Diff<?php if ($view_register_master->CashDiff->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_register_master->CashDiff->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top">
<?php if ($view_register_master->Export <> "") { ?>
Cash Adj
<?php } else { ?>
	<a href="view_register_masterlist.php?order=<?php echo urlencode('CashAdj') ?>&ordertype=<?php echo $view_register_master->CashAdj->ReverseSort() ?>">Cash Adj<?php if ($view_register_master->CashAdj->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_register_master->CashAdj->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top">
<?php if ($view_register_master->Export <> "") { ?>
Other Adj
<?php } else { ?>
	<a href="view_register_masterlist.php?order=<?php echo urlencode('OtherAdj') ?>&ordertype=<?php echo $view_register_master->OtherAdj->ReverseSort() ?>">Other Adj<?php if ($view_register_master->OtherAdj->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_register_master->OtherAdj->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top">
<?php if ($view_register_master->Export <> "") { ?>
Reg Total
<?php } else { ?>
	<a href="view_register_masterlist.php?order=<?php echo urlencode('RegisterTotal') ?>&ordertype=<?php echo $view_register_master->RegisterTotal->ReverseSort() ?>">RegTotal NetSales<?php if ($view_register_master->RegisterTotal->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_register_master->RegisterTotal->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
		<td valign="top">
<?php if ($view_register_master->Export <> "") { ?>
Short Over
<?php } else { ?>
	<a href="view_register_masterlist.php?order=<?php echo urlencode('Short_Over') ?>&ordertype=<?php echo $view_register_master->Short_Over->ReverseSort() ?>">Short Over<?php if ($view_register_master->Short_Over->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($view_register_master->Short_Over->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
<?php } ?>
		</td>
<?php if ($view_register_master->Export == "") { ?>
<?php } ?>
	</tr>
<?php
if (defined("EW_EXPORT_ALL") && $view_register_master->Export <> "") {
	$nStopRec = $nTotalRecs;
} else {
	$nStopRec = $nStartRec + $nDisplayRecs - 1; // Set the last record to display
}
$nRecCount = $nStartRec - 1;
if (!$rs->EOF) {
	$rs->MoveFirst();
	if (!$view_register_master->SelectLimit) $rs->Move($nStartRec - 1); // Move to first record directly
}
$RowCnt = 0;
while (!$rs->EOF && $nRecCount < $nStopRec) {
	$nRecCount++;
	if (intval($nRecCount) >= intval($nStartRec)) {
		$RowCnt++;

	// Init row class and style
	$view_register_master->CssClass = "ewTableRow";
	$view_register_master->CssStyle = "";

	// Init row event
	$view_register_master->RowClientEvents = "onmouseover='ew_MouseOver(this);' onmouseout='ew_MouseOut(this);' onclick='ew_Click(this);'";

	// Display alternate color for rows
	if ($RowCnt % 2 == 0) {
		$view_register_master->CssClass = "ewTableAltRow";
	}
	LoadRowValues($rs); // Load row values
	$view_register_master->RowType = EW_ROWTYPE_VIEW; // Render view
	RenderRow();
?>
	<!-- Table body -->
	<tr<?php echo $view_register_master->DisplayAttributes() ?>>
		<!-- MonthYear -->
		<td<?php echo $view_register_master->MonthYear->CellAttributes() ?>>
<div<?php echo $view_register_master->MonthYear->ViewAttributes() ?>><?php echo $view_register_master->MonthYear->ViewValue ?></div>
</td>
		<!-- ID -->
		<td<?php echo $view_register_master->ID->CellAttributes() ?>>
<div<?php echo $view_register_master->ID->ViewAttributes() ?>><?php echo $view_register_master->ID->ViewValue ?></div>
</td>
		<!-- PreviousID -->
		<td<?php echo $view_register_master->PreviousID->CellAttributes() ?>>
<div<?php echo $view_register_master->PreviousID->ViewAttributes() ?>><?php echo $view_register_master->PreviousID->ViewValue ?></div>
</td>
		<!-- LogDate -->
		<td<?php echo $view_register_master->LogDate->CellAttributes() ?>>
<div<?php echo $view_register_master->LogDate->ViewAttributes() ?>><?php echo $view_register_master->LogDate->ViewValue ?></div>
</td>
		<!-- PrevLogDate -->
		<td<?php echo $view_register_master->PrevLogDate->CellAttributes() ?>>
<div<?php echo $view_register_master->PrevLogDate->ViewAttributes() ?>><?php echo $view_register_master->PrevLogDate->ViewValue ?></div>
</td>
		<!-- Link -->
		<td<?php echo $view_register_master->Link->CellAttributes() ?>>
<?php if ($view_register_master->Link->HrefValue <> "") { ?>
<a href="ActivityLog2.php?ID=<?php echo addslashes(html_entity_decode(base64_encode( $view_register_master->Link->HrefValue ))) ;  ?>" target="_self"><div<?php echo $view_register_master->Link->ViewAttributes() ?>><?php echo $view_register_master->Link->ViewValue ?></div></a>
<?php } else { ?>
<div<?php echo $view_register_master->Link->ViewAttributes() ?>><?php echo $view_register_master->Link->ViewValue ?></div>
<?php } ?>
</td>
		<!-- XReading -->
		<td<?php echo $view_register_master->XReading->CellAttributes() ?>>
<div<?php echo $view_register_master->XReading->ViewAttributes() ?>><?php echo $view_register_master->XReading->ViewValue ?></div>
</td>
		<!-- YesterdayXReading -->
		<td<?php echo $view_register_master->YesterdayXReading->CellAttributes() ?>>
<div<?php echo $view_register_master->YesterdayXReading->ViewAttributes() ?>><?php echo $view_register_master->YesterdayXReading->ViewValue ?></div>
</td>
		<!-- DiffXreading -->
		<td<?php echo $view_register_master->DiffXreading->CellAttributes() ?>>
<div<?php echo $view_register_master->DiffXreading->ViewAttributes() ?>><?php echo $view_register_master->DiffXreading->ViewValue ?></div>
</td>
		<!-- CheckAmount -->
		<td<?php echo $view_register_master->CheckAmount->CellAttributes() ?>>
<div<?php echo $view_register_master->CheckAmount->ViewAttributes() ?>><?php echo $view_register_master->CheckAmount->ViewValue ?></div>
</td>
		<!-- LunchAmount -->
		<td<?php echo $view_register_master->LunchAmount->CellAttributes() ?>>
<div<?php echo $view_register_master->LunchAmount->ViewAttributes() ?>><?php echo $view_register_master->LunchAmount->ViewValue ?></div>
</td>
		<!-- OverAmount -->
		<td<?php echo $view_register_master->OverAmount->CellAttributes() ?>>
<div<?php echo $view_register_master->OverAmount->ViewAttributes() ?>><?php echo $view_register_master->OverAmount->ViewValue ?></div>
</td>
		<!-- CreditAmount -->
		<td<?php echo $view_register_master->CreditAmount->CellAttributes() ?>>
<div<?php echo $view_register_master->CreditAmount->ViewAttributes() ?>><?php echo $view_register_master->CreditAmount->ViewValue ?></div>
</td>
		<!-- PayoutAmount -->
		<td<?php echo $view_register_master->PayoutAmount->CellAttributes() ?>>
<div<?php echo $view_register_master->PayoutAmount->ViewAttributes() ?>><?php echo $view_register_master->PayoutAmount->ViewValue ?></div>
</td>
		<!-- TotalDrawAmount -->
		<td<?php echo $view_register_master->TotalDrawAmount->CellAttributes() ?>>
<div<?php echo $view_register_master->TotalDrawAmount->ViewAttributes() ?>><?php echo $view_register_master->TotalDrawAmount->ViewValue ?></div>
</td>
		<!-- PreviousDrawAmount -->
		<td<?php echo $view_register_master->PreviousDrawAmount->CellAttributes() ?>>
<div<?php echo $view_register_master->PreviousDrawAmount->ViewAttributes() ?>><?php echo $view_register_master->PreviousDrawAmount->ViewValue ?></div>
</td>
		<!-- CashDiff -->
		<td<?php echo $view_register_master->CashDiff->CellAttributes() ?>>
<div<?php echo $view_register_master->CashDiff->ViewAttributes() ?>><?php echo $view_register_master->CashDiff->ViewValue ?></div>
</td>
		<!-- CashAdj -->
		<td<?php echo $view_register_master->CashAdj->CellAttributes() ?>>
<div<?php echo $view_register_master->CashAdj->ViewAttributes() ?>><?php echo $view_register_master->CashAdj->ViewValue ?></div>
</td>
		<!-- OtherAdj -->
		<td<?php echo $view_register_master->OtherAdj->CellAttributes() ?>>
<div<?php echo $view_register_master->OtherAdj->ViewAttributes() ?>><?php echo $view_register_master->OtherAdj->ViewValue ?></div>
</td>
		<!-- RegisterTotal -->
		<td<?php echo $view_register_master->RegisterTotal->CellAttributes() ?>>
<div<?php echo $view_register_master->RegisterTotal->ViewAttributes() ?>><?php echo $view_register_master->RegisterTotal->ViewValue ?></div>
</td>
		<!-- Short_Over -->
		<td<?php echo $view_register_master->Short_Over->CellAttributes() ?>>
<div<?php echo $view_register_master->Short_Over->ViewAttributes() ?>><?php echo $view_register_master->Short_Over->ViewValue ?></div>
</td>
<?php if ($view_register_master->Export == "") { ?>
<?php } ?>
	</tr>
<?php
	}
	$rs->MoveNext();
}
?>
</table>
<?php if ($view_register_master->Export == "") { ?>
<table>
	<tr><td><span class="phpmaker">
	</span></td></tr>
</table>
<?php } ?>
<?php } ?>
</form>
<?php

// Close recordset and connection
if ($rs) $rs->Close();
?>
<?php if ($view_register_master->Export == "") { ?>
<form action="view_register_masterlist.php" name="ewpagerform" id="ewpagerform">
<table border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td nowrap>
<?php if (!isset($Pager)) $Pager = new cPrevNextPager($nStartRec, $nDisplayRecs, $nTotalRecs) ?>
<?php if ($Pager->RecordCount > 0) { ?>
	<table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="phpmaker">Page&nbsp;</span></td>
<!--first page button-->
	<?php if ($Pager->FirstButton->Enabled) { ?>
	<td><a href="view_register_masterlist.php?start=<?php echo $Pager->FirstButton->Start ?>"><img src="images/first.gif" alt="First" width="16" height="16" border="0"></a></td>
	<?php } else { ?>
	<td><img src="images/firstdisab.gif" alt="First" width="16" height="16" border="0"></td>
	<?php } ?>
<!--previous page button-->
	<?php if ($Pager->PrevButton->Enabled) { ?>
	<td><a href="view_register_masterlist.php?start=<?php echo $Pager->PrevButton->Start ?>"><img src="images/prev.gif" alt="Previous" width="16" height="16" border="0"></a></td>
	<?php } else { ?>
	<td><img src="images/prevdisab.gif" alt="Previous" width="16" height="16" border="0"></td>
	<?php } ?>
<!--current page number-->
	<td><input type="text" name="<?php echo EW_TABLE_PAGE_NO ?>" id="<?php echo EW_TABLE_PAGE_NO ?>" value="<?php echo $Pager->CurrentPage ?>" size="4"></td>
<!--next page button-->
	<?php if ($Pager->NextButton->Enabled) { ?>
	<td><a href="view_register_masterlist.php?start=<?php echo $Pager->NextButton->Start ?>"><img src="images/next.gif" alt="Next" width="16" height="16" border="0"></a></td>	
	<?php } else { ?>
	<td><img src="images/nextdisab.gif" alt="Next" width="16" height="16" border="0"></td>
	<?php } ?>
<!--last page button-->
	<?php if ($Pager->LastButton->Enabled) { ?>
	<td><a href="view_register_masterlist.php?start=<?php echo $Pager->LastButton->Start ?>"><img src="images/last.gif" alt="Last" width="16" height="16" border="0"></a></td>	
	<?php } else { ?>
	<td><img src="images/lastdisab.gif" alt="Last" width="16" height="16" border="0"></td>
	<?php } ?>
	<td><span class="phpmaker">&nbsp;of <?php echo $Pager->PageCount ?></span></td>
	</tr></table>
	<span class="phpmaker">Records <?php echo $Pager->FromIndex ?> to <?php echo $Pager->ToIndex ?> of <?php echo $Pager->RecordCount ?></span>
<?php } else { ?>
	<?php if ($sSrchWhere == "0=101") { ?>
	<span class="phpmaker">Please enter search criteria</span>
	<?php } else { ?>
	<span class="phpmaker">No records found</span>
	<?php } ?>
<?php } ?>
		</td>
<?php if ($nTotalRecs > 0) { ?>
		<td nowrap>&nbsp;&nbsp;&nbsp;&nbsp;</td>
		<td align="right" valign="top" nowrap><span class="phpmaker">Records Per Page&nbsp;
<select name="<?php echo EW_TABLE_REC_PER_PAGE ?>" id="<?php echo EW_TABLE_REC_PER_PAGE ?>" onChange="this.form.submit();" class="phpmaker">
<option value="20"<?php if ($nDisplayRecs == 20) echo " selected" ?>>20</option>
<option value="ALL"<?php if ($view_register_master->getRecordsPerPage() == -1) echo " selected" ?>>All Records</option>
</select>
		</span></td>
<?php } ?>
	</tr>
</table>
</form>
<?php } ?>
<?php if ($view_register_master->Export == "") { ?>
<?php } ?>
<?php if ($view_register_master->Export == "") { ?>
<script language="JavaScript" type="text/javascript">
<!--

// Write your table-specific startup script here
// document.write("page loaded");
//-->

</script>
<?php } ?>
<?php include "footer.php" ?>
<?php

// If control is passed here, simply terminate the page without redirect
Page_Terminate();

// -----------------------------------------------------------------
//  Subroutine Page_Terminate
//  - called when exit page
//  - clean up connection and objects
//  - if url specified, redirect to url, otherwise end response
function Page_Terminate($url = "") {
	global $conn;

	// Page unload event, used in current page
	Page_Unload();

	// Global page unloaded event (in userfn*.php)
	Page_Unloaded();

	 // Close Connection
	$conn->Close();

	// Go to url if specified
	if ($url <> "") {
		ob_end_clean();
		header("Location: $url");
	}
	exit();
}
?>
<?php

// Set up number of records displayed per page
function SetUpDisplayRecs() {
	global $nDisplayRecs, $nStartRec, $view_register_master;
	$sWrk = @$_GET[EW_TABLE_REC_PER_PAGE];
	if ($sWrk <> "") {
		if (is_numeric($sWrk)) {
			$nDisplayRecs = intval($sWrk);
		} else {
			if (strtolower($sWrk) == "all") { // Display all records
				$nDisplayRecs = -1;
			} else {
				$nDisplayRecs = 20; // Non-numeric, load default
			}
		}
		$view_register_master->setRecordsPerPage($nDisplayRecs); // Save to Session

		// Reset start position
		$nStartRec = 1;
		$view_register_master->setStartRecordNumber($nStartRec);
	} else {
		if ($view_register_master->getRecordsPerPage() <> "") {
			$nDisplayRecs = $view_register_master->getRecordsPerPage(); // Restore from Session
		} else {
			$nDisplayRecs = 20; // Load default
		}
	}
}

// Return Basic Search sql
function BasicSearchSQL($Keyword) {
	$sKeyword = ew_AdjustSql($Keyword);
	$sql = "";
	$sql .= "`MonthYear` LIKE '%" . $sKeyword . "%' OR ";
	$sql .= "`Link` LIKE '%" . $sKeyword . "%' OR ";
	if (is_numeric($sKeyword)) $sql .= "`CreditAmount` = " . $sKeyword . " OR ";
	if (is_numeric($sKeyword)) $sql .= "`PayoutAmount` = " . $sKeyword . " OR ";
	if (is_numeric($sKeyword)) $sql .= "`TotalDrawAmount` = " . $sKeyword . " OR ";
	if (substr($sql, -4) == " OR ") $sql = substr($sql, 0, strlen($sql)-4);
	return $sql;
}

// Return Basic Search Where based on search keyword and type
function BasicSearchWhere() {
	global $Security, $view_register_master;
	$sSearchStr = "";
	$sSearchKeyword = ew_StripSlashes(@$_GET[EW_TABLE_BASIC_SEARCH]);
	$sSearchType = @$_GET[EW_TABLE_BASIC_SEARCH_TYPE];
	if ($sSearchKeyword <> "") {
		$sSearch = trim($sSearchKeyword);
		if ($sSearchType <> "") {
			while (strpos($sSearch, "  ") !== FALSE)
				$sSearch = str_replace("  ", " ", $sSearch);
			$arKeyword = explode(" ", trim($sSearch));
			foreach ($arKeyword as $sKeyword) {
				if ($sSearchStr <> "") $sSearchStr .= " " . $sSearchType . " ";
				$sSearchStr .= "(" . BasicSearchSQL($sKeyword) . ")";
			}
		} else {
			$sSearchStr = BasicSearchSQL($sSearch);
		}
	}
	if ($sSearchKeyword <> "") {
		$view_register_master->setBasicSearchKeyword($sSearchKeyword);
		$view_register_master->setBasicSearchType($sSearchType);
	}
	return $sSearchStr;
}

// Clear all search parameters
function ResetSearchParms() {

	// Clear search where
	global $view_register_master;
	$sSrchWhere = "";
	$view_register_master->setSearchWhere($sSrchWhere);

	// Clear basic search parameters
	ResetBasicSearchParms();
}

// Clear all basic search parameters
function ResetBasicSearchParms() {

	// Clear basic search parameters
	global $view_register_master;
	$view_register_master->setBasicSearchKeyword("");
	$view_register_master->setBasicSearchType("");
}

// Restore all search parameters
function RestoreSearchParms() {
	global $sSrchWhere, $view_register_master;
	$sSrchWhere = $view_register_master->getSearchWhere();
}

// Set up Sort parameters based on Sort Links clicked
function SetUpSortOrder() {
	global $view_register_master;

	// Check for an Order parameter
	if (@$_GET["order"] <> "") {
		$view_register_master->CurrentOrder = ew_StripSlashes(@$_GET["order"]);
		$view_register_master->CurrentOrderType = @$_GET["ordertype"];

		// Field MonthYear
		$view_register_master->UpdateSort($view_register_master->MonthYear);

		// Field ID
		$view_register_master->UpdateSort($view_register_master->ID);

		// Field PreviousID
		$view_register_master->UpdateSort($view_register_master->PreviousID);

		// Field LogDate
		$view_register_master->UpdateSort($view_register_master->LogDate);

		// Field PrevLogDate
		$view_register_master->UpdateSort($view_register_master->PrevLogDate);

		// Field Link
		$view_register_master->UpdateSort($view_register_master->Link);

		// Field XReading
		$view_register_master->UpdateSort($view_register_master->XReading);

		// Field YesterdayXReading
		$view_register_master->UpdateSort($view_register_master->YesterdayXReading);

		// Field DiffXreading
		$view_register_master->UpdateSort($view_register_master->DiffXreading);

		// Field CheckAmount
		$view_register_master->UpdateSort($view_register_master->CheckAmount);

		// Field LunchAmount
		$view_register_master->UpdateSort($view_register_master->LunchAmount);

		// Field OverAmount
		$view_register_master->UpdateSort($view_register_master->OverAmount);

		// Field CreditAmount
		$view_register_master->UpdateSort($view_register_master->CreditAmount);

		// Field PayoutAmount
		$view_register_master->UpdateSort($view_register_master->PayoutAmount);

		// Field TotalDrawAmount
		$view_register_master->UpdateSort($view_register_master->TotalDrawAmount);

		// Field PreviousDrawAmount
		$view_register_master->UpdateSort($view_register_master->PreviousDrawAmount);

		// Field CashDiff
		$view_register_master->UpdateSort($view_register_master->CashDiff);

		// Field CashAdj
		$view_register_master->UpdateSort($view_register_master->CashAdj);

		// Field OtherAdj
		$view_register_master->UpdateSort($view_register_master->OtherAdj);

		// Field RegisterTotal
		$view_register_master->UpdateSort($view_register_master->RegisterTotal);

		// Field Short_Over
		$view_register_master->UpdateSort($view_register_master->Short_Over);
		$view_register_master->setStartRecordNumber(1); // Reset start position
	}
	$sOrderBy = $view_register_master->getSessionOrderBy(); // Get order by from Session
	if ($sOrderBy == "") {
		if ($view_register_master->SqlOrderBy() <> "") {
			$sOrderBy = $view_register_master->SqlOrderBy();
			$view_register_master->setSessionOrderBy($sOrderBy);
		}
	}
}

// Reset command based on querystring parameter cmd=
// - RESET: reset search parameters
// - RESETALL: reset search & master/detail parameters
// - RESETSORT: reset sort parameters
function ResetCmd() {
	global $sDbMasterFilter, $sDbDetailFilter, $nStartRec, $sOrderBy;
	global $view_register_master;

	// Get reset cmd
	if (@$_GET["cmd"] <> "") {
		$sCmd = $_GET["cmd"];

		// Reset search criteria
		if (strtolower($sCmd) == "reset" || strtolower($sCmd) == "resetall") {
			ResetSearchParms();
		}

		// Reset Sort Criteria
		if (strtolower($sCmd) == "resetsort") {
			$sOrderBy = "";
			$view_register_master->setSessionOrderBy($sOrderBy);
			$view_register_master->MonthYear->setSort("");
			$view_register_master->ID->setSort("");
			$view_register_master->PreviousID->setSort("");
			$view_register_master->LogDate->setSort("");
			$view_register_master->PrevLogDate->setSort("");
			$view_register_master->Link->setSort("");
			$view_register_master->XReading->setSort("");
			$view_register_master->YesterdayXReading->setSort("");
			$view_register_master->DiffXreading->setSort("");
			$view_register_master->CheckAmount->setSort("");
			$view_register_master->LunchAmount->setSort("");
			$view_register_master->OverAmount->setSort("");
			$view_register_master->CreditAmount->setSort("");
			$view_register_master->PayoutAmount->setSort("");
			$view_register_master->TotalDrawAmount->setSort("");
			$view_register_master->PreviousDrawAmount->setSort("");
			$view_register_master->CashDiff->setSort("");
			$view_register_master->CashAdj->setSort("");
			$view_register_master->OtherAdj->setSort("");
			$view_register_master->RegisterTotal->setSort("");
			$view_register_master->Short_Over->setSort("");
		}

		// Reset start position
		$nStartRec = 1;
		$view_register_master->setStartRecordNumber($nStartRec);
	}
}
?>
<?php

// Set up Starting Record parameters based on Pager Navigation
function SetUpStartRec() {
	global $nDisplayRecs, $nStartRec, $nTotalRecs, $nPageNo, $view_register_master;
	if ($nDisplayRecs == 0) return;

	// Check for a START parameter
	if (@$_GET[EW_TABLE_START_REC] <> "") {
		$nStartRec = $_GET[EW_TABLE_START_REC];
		$view_register_master->setStartRecordNumber($nStartRec);
	} elseif (@$_GET[EW_TABLE_PAGE_NO] <> "") {
		$nPageNo = $_GET[EW_TABLE_PAGE_NO];
		if (is_numeric($nPageNo)) {
			$nStartRec = ($nPageNo-1)*$nDisplayRecs+1;
			if ($nStartRec <= 0) {
				$nStartRec = 1;
			} elseif ($nStartRec >= intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1) {
				$nStartRec = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1;
			}
			$view_register_master->setStartRecordNumber($nStartRec);
		} else {
			$nStartRec = $view_register_master->getStartRecordNumber();
		}
	} else {
		$nStartRec = $view_register_master->getStartRecordNumber();
	}

	// Check if correct start record counter
	if (!is_numeric($nStartRec) || $nStartRec == "") { // Avoid invalid start record counter
		$nStartRec = 1; // Reset start record counter
		$view_register_master->setStartRecordNumber($nStartRec);
	} elseif (intval($nStartRec) > intval($nTotalRecs)) { // Avoid starting record > total records
		$nStartRec = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1; // Point to last page first record
		$view_register_master->setStartRecordNumber($nStartRec);
	} elseif (($nStartRec-1) % $nDisplayRecs <> 0) {
		$nStartRec = intval(($nStartRec-1)/$nDisplayRecs)*$nDisplayRecs+1; // Point to page boundary
		$view_register_master->setStartRecordNumber($nStartRec);
	}
}
?>
<?php

// Load recordset
function LoadRecordset($offset = -1, $rowcnt = -1) {
	global $conn, $view_register_master;

	// Call Recordset Selecting event
	$view_register_master->Recordset_Selecting($view_register_master->CurrentFilter);

	// Load list page sql
	$sSql = $view_register_master->SelectSQL();
	if ($offset > -1 && $rowcnt > -1) $sSql .= " LIMIT $offset, $rowcnt";

	// Load recordset
	$conn->raiseErrorFn = 'ew_ErrorFn';	
	$rs = $conn->Execute($sSql);
	$conn->raiseErrorFn = '';

	// Call Recordset Selected event
	$view_register_master->Recordset_Selected($rs);
	return $rs;
}
?>
<?php

// Load row based on key values
function LoadRow() {
	global $conn, $Security, $view_register_master;
	$sFilter = $view_register_master->SqlKeyFilter();
	if (!is_numeric($view_register_master->ID->CurrentValue)) {
		return FALSE; // Invalid key, exit
	}
	$sFilter = str_replace("@ID@", ew_AdjustSql($view_register_master->ID->CurrentValue), $sFilter); // Replace key value

	// Call Row Selecting event
	$view_register_master->Row_Selecting($sFilter);

	// Load sql based on filter
	$view_register_master->CurrentFilter = $sFilter;
	$sSql = $view_register_master->SQL();
	if ($rs = $conn->Execute($sSql)) {
		if ($rs->EOF) {
			$LoadRow = FALSE;
		} else {
			$LoadRow = TRUE;
			$rs->MoveFirst();
			LoadRowValues($rs); // Load row values

			// Call Row Selected event
			$view_register_master->Row_Selected($rs);
		}
		$rs->Close();
	} else {
		$LoadRow = FALSE;
	}
	return $LoadRow;
}

// Load row values from recordset
function LoadRowValues(&$rs) {
	global $view_register_master;
	$view_register_master->MonthYear->setDbValue($rs->fields('MonthYear'));
	$view_register_master->ID->setDbValue($rs->fields('ID'));
	$view_register_master->PreviousID->setDbValue($rs->fields('PreviousID'));
	$view_register_master->LogDate->setDbValue($rs->fields('LogDate'));
	$view_register_master->PrevLogDate->setDbValue($rs->fields('PrevLogDate'));
	$view_register_master->Link->setDbValue($rs->fields('Link'));
	$view_register_master->XReading->setDbValue($rs->fields('XReading'));
	$view_register_master->YesterdayXReading->setDbValue($rs->fields('YesterdayXReading'));
	$view_register_master->DiffXreading->setDbValue($rs->fields('DiffXreading'));
	$view_register_master->CheckAmount->setDbValue($rs->fields('CheckAmount'));
	$view_register_master->LunchAmount->setDbValue($rs->fields('LunchAmount'));
	$view_register_master->OverAmount->setDbValue($rs->fields('OverAmount'));
	$view_register_master->CreditAmount->setDbValue($rs->fields('CreditAmount'));
	$view_register_master->PayoutAmount->setDbValue($rs->fields('PayoutAmount'));
	$view_register_master->TotalDrawAmount->setDbValue($rs->fields('TotalDrawAmount'));
	$view_register_master->PreviousDrawAmount->setDbValue($rs->fields('PreviousDrawAmount'));
	$view_register_master->CashDiff->setDbValue($rs->fields('CashDiff'));
	$view_register_master->CashAdj->setDbValue($rs->fields('CashAdj'));
	$view_register_master->OtherAdj->setDbValue($rs->fields('OtherAdj'));
	$view_register_master->RegisterTotal->setDbValue($rs->fields('RegisterTotal'));
	$view_register_master->Short_Over->setDbValue($rs->fields('Short_Over'));
}
?>
<?php

// Render row values based on field settings
function RenderRow() {
	global $conn, $Security, $view_register_master;

	// Call Row Rendering event
	$view_register_master->Row_Rendering();

	// Common render codes for all row types
	// MonthYear

	$view_register_master->MonthYear->CellCssStyle = "white-space: nowrap;";
	$view_register_master->MonthYear->CellCssClass = "";

	// ID
	$view_register_master->ID->CellCssStyle = "";
	$view_register_master->ID->CellCssClass = "";

	// PreviousID
	$view_register_master->PreviousID->CellCssStyle = "";
	$view_register_master->PreviousID->CellCssClass = "";

	// LogDate
	$view_register_master->LogDate->CellCssStyle = "";
	$view_register_master->LogDate->CellCssClass = "";

	// PrevLogDate
	$view_register_master->PrevLogDate->CellCssStyle = "";
	$view_register_master->PrevLogDate->CellCssClass = "";

	// Link
	$view_register_master->Link->CellCssStyle = "white-space: nowrap;";
	$view_register_master->Link->CellCssClass = "";

	// XReading
	$view_register_master->XReading->CellCssStyle = "";
	$view_register_master->XReading->CellCssClass = "";

	// YesterdayXReading
	$view_register_master->YesterdayXReading->CellCssStyle = "";
	$view_register_master->YesterdayXReading->CellCssClass = "";

	// DiffXreading
	$view_register_master->DiffXreading->CellCssStyle = "";
	$view_register_master->DiffXreading->CellCssClass = "";

	// CheckAmount
	$view_register_master->CheckAmount->CellCssStyle = "";
	$view_register_master->CheckAmount->CellCssClass = "";

	// LunchAmount
	$view_register_master->LunchAmount->CellCssStyle = "";
	$view_register_master->LunchAmount->CellCssClass = "";

	// OverAmount
	$view_register_master->OverAmount->CellCssStyle = "";
	$view_register_master->OverAmount->CellCssClass = "";

	// CreditAmount
	$view_register_master->CreditAmount->CellCssStyle = "";
	$view_register_master->CreditAmount->CellCssClass = "";

	// PayoutAmount
	$view_register_master->PayoutAmount->CellCssStyle = "";
	$view_register_master->PayoutAmount->CellCssClass = "";

	// TotalDrawAmount
	$view_register_master->TotalDrawAmount->CellCssStyle = "";
	$view_register_master->TotalDrawAmount->CellCssClass = "";

	// PreviousDrawAmount
	$view_register_master->PreviousDrawAmount->CellCssStyle = "";
	$view_register_master->PreviousDrawAmount->CellCssClass = "";

	// CashDiff
	$view_register_master->CashDiff->CellCssStyle = "";
	$view_register_master->CashDiff->CellCssClass = "";

	// CashAdj
	$view_register_master->CashAdj->CellCssStyle = "";
	$view_register_master->CashAdj->CellCssClass = "";

	// OtherAdj
	$view_register_master->OtherAdj->CellCssStyle = "";
	$view_register_master->OtherAdj->CellCssClass = "";

	// RegisterTotal
	$view_register_master->RegisterTotal->CellCssStyle = "";
	$view_register_master->RegisterTotal->CellCssClass = "";

	// Short_Over
	$view_register_master->Short_Over->CellCssStyle = "";
	$view_register_master->Short_Over->CellCssClass = "";
	if ($view_register_master->RowType == EW_ROWTYPE_VIEW) { // View row

		// MonthYear
		$view_register_master->MonthYear->ViewValue = $view_register_master->MonthYear->CurrentValue;
		$view_register_master->MonthYear->CssStyle = "";
		$view_register_master->MonthYear->CssClass = "";
		$view_register_master->MonthYear->ViewCustomAttributes = "";

		// ID
		$view_register_master->ID->ViewValue = $view_register_master->ID->CurrentValue;
		$view_register_master->ID->CssStyle = "";
		$view_register_master->ID->CssClass = "";
		$view_register_master->ID->ViewCustomAttributes = "";

		// PreviousID
		$view_register_master->PreviousID->ViewValue = $view_register_master->PreviousID->CurrentValue;
		$view_register_master->PreviousID->CssStyle = "";
		$view_register_master->PreviousID->CssClass = "";
		$view_register_master->PreviousID->ViewCustomAttributes = "";

		// LogDate
		$view_register_master->LogDate->ViewValue = $view_register_master->LogDate->CurrentValue;
		$view_register_master->LogDate->ViewValue = ew_FormatDateTime($view_register_master->LogDate->ViewValue, 5);
		$view_register_master->LogDate->CssStyle = "";
		$view_register_master->LogDate->CssClass = "";
		$view_register_master->LogDate->ViewCustomAttributes = "";

		// PrevLogDate
		$view_register_master->PrevLogDate->ViewValue = $view_register_master->PrevLogDate->CurrentValue;
		$view_register_master->PrevLogDate->ViewValue = ew_FormatDateTime($view_register_master->PrevLogDate->ViewValue, 5);
		$view_register_master->PrevLogDate->CssStyle = "";
		$view_register_master->PrevLogDate->CssClass = "";
		$view_register_master->PrevLogDate->ViewCustomAttributes = "";

		// Link
		$view_register_master->Link->ViewValue = $view_register_master->Link->CurrentValue;
		$view_register_master->Link->CssStyle = "";
		$view_register_master->Link->CssClass = "";
		$view_register_master->Link->ViewCustomAttributes = "";

		// XReading
		$view_register_master->XReading->ViewValue = $view_register_master->XReading->CurrentValue;
		$view_register_master->XReading->ViewValue = ew_FormatNumber($view_register_master->XReading->ViewValue, 2, -2, -1, -2);
		$view_register_master->XReading->CssStyle = "";
		$view_register_master->XReading->CssClass = "";
		$view_register_master->XReading->ViewCustomAttributes = "";

		// YesterdayXReading
		$view_register_master->YesterdayXReading->ViewValue = $view_register_master->YesterdayXReading->CurrentValue;
		$view_register_master->YesterdayXReading->ViewValue = ew_FormatNumber($view_register_master->YesterdayXReading->ViewValue, 2, -2, -1, -2);
		$view_register_master->YesterdayXReading->CssStyle = "";
		$view_register_master->YesterdayXReading->CssClass = "";
		$view_register_master->YesterdayXReading->ViewCustomAttributes = "";

		// DiffXreading
		$view_register_master->DiffXreading->ViewValue = $view_register_master->DiffXreading->CurrentValue;
		$view_register_master->DiffXreading->ViewValue = ew_FormatNumber($view_register_master->DiffXreading->ViewValue, 2, -1, -1, -2);
		$view_register_master->DiffXreading->CssStyle = "";
		$view_register_master->DiffXreading->CssClass = "";
		$view_register_master->DiffXreading->ViewCustomAttributes = "";

		// CheckAmount
		$view_register_master->CheckAmount->ViewValue = $view_register_master->CheckAmount->CurrentValue;
		$view_register_master->CheckAmount->ViewValue = ew_FormatNumber($view_register_master->CheckAmount->ViewValue, 2, -2, -1, -2);
		$view_register_master->CheckAmount->CssStyle = "";
		$view_register_master->CheckAmount->CssClass = "";
		$view_register_master->CheckAmount->ViewCustomAttributes = "";

		// LunchAmount
		$view_register_master->LunchAmount->ViewValue = $view_register_master->LunchAmount->CurrentValue;
		$view_register_master->LunchAmount->ViewValue = ew_FormatNumber($view_register_master->LunchAmount->ViewValue, 2, -2, -1, -2);
		$view_register_master->LunchAmount->CssStyle = "";
		$view_register_master->LunchAmount->CssClass = "";
		$view_register_master->LunchAmount->ViewCustomAttributes = "";

		// OverAmount
		$view_register_master->OverAmount->ViewValue = $view_register_master->OverAmount->CurrentValue;
		$view_register_master->OverAmount->ViewValue = ew_FormatNumber($view_register_master->OverAmount->ViewValue, 2, -2, -1, -2);
		$view_register_master->OverAmount->CssStyle = "";
		$view_register_master->OverAmount->CssClass = "";
		$view_register_master->OverAmount->ViewCustomAttributes = "";

		// CreditAmount
		$view_register_master->CreditAmount->ViewValue = $view_register_master->CreditAmount->CurrentValue;
		$view_register_master->CreditAmount->ViewValue = ew_FormatNumber($view_register_master->CreditAmount->ViewValue, 2, -2, -1, -2);
		$view_register_master->CreditAmount->CssStyle = "";
		$view_register_master->CreditAmount->CssClass = "";
		$view_register_master->CreditAmount->ViewCustomAttributes = "";

		// PayoutAmount
		$view_register_master->PayoutAmount->ViewValue = $view_register_master->PayoutAmount->CurrentValue;
		$view_register_master->PayoutAmount->ViewValue = ew_FormatNumber($view_register_master->PayoutAmount->ViewValue, 2, -2, -1, -2);
		$view_register_master->PayoutAmount->CssStyle = "";
		$view_register_master->PayoutAmount->CssClass = "";
		$view_register_master->PayoutAmount->ViewCustomAttributes = "";

		// TotalDrawAmount
		$view_register_master->TotalDrawAmount->ViewValue = $view_register_master->TotalDrawAmount->CurrentValue;
		$view_register_master->TotalDrawAmount->ViewValue = ew_FormatNumber($view_register_master->TotalDrawAmount->ViewValue, 2, -1, -1, -2);
		$view_register_master->TotalDrawAmount->CssStyle = "";
		$view_register_master->TotalDrawAmount->CssClass = "";
		$view_register_master->TotalDrawAmount->ViewCustomAttributes = "";

		// PreviousDrawAmount
		$view_register_master->PreviousDrawAmount->ViewValue = $view_register_master->PreviousDrawAmount->CurrentValue;
		$view_register_master->PreviousDrawAmount->ViewValue = ew_FormatNumber($view_register_master->PreviousDrawAmount->ViewValue, 2, -2, -1, -2);
		$view_register_master->PreviousDrawAmount->CssStyle = "";
		$view_register_master->PreviousDrawAmount->CssClass = "";
		$view_register_master->PreviousDrawAmount->ViewCustomAttributes = "";

		// CashDiff
		$view_register_master->CashDiff->ViewValue = $view_register_master->CashDiff->CurrentValue;
		$view_register_master->CashDiff->ViewValue = ew_FormatNumber($view_register_master->CashDiff->ViewValue, 2, -2, -1, -2);
		$view_register_master->CashDiff->CssStyle = "";
		$view_register_master->CashDiff->CssClass = "";
		$view_register_master->CashDiff->ViewCustomAttributes = "";

		// CashAdj
		$view_register_master->CashAdj->ViewValue = $view_register_master->CashAdj->CurrentValue;
		$view_register_master->CashAdj->ViewValue = ew_FormatNumber($view_register_master->CashAdj->ViewValue, 2, -2, -1, -2);
		$view_register_master->CashAdj->CssStyle = "";
		$view_register_master->CashAdj->CssClass = "";
		$view_register_master->CashAdj->ViewCustomAttributes = "";

		// OtherAdj
		$view_register_master->OtherAdj->ViewValue = $view_register_master->OtherAdj->CurrentValue;
		$view_register_master->OtherAdj->ViewValue = ew_FormatNumber($view_register_master->OtherAdj->ViewValue, 2, -2, -1, -2);
		$view_register_master->OtherAdj->CssStyle = "";
		$view_register_master->OtherAdj->CssClass = "";
		$view_register_master->OtherAdj->ViewCustomAttributes = "";

		// RegisterTotal
		$view_register_master->RegisterTotal->ViewValue = $view_register_master->RegisterTotal->CurrentValue;
		$view_register_master->RegisterTotal->ViewValue = ew_FormatNumber($view_register_master->RegisterTotal->ViewValue, 2, -2, -1, -2);
		$view_register_master->RegisterTotal->CssStyle = "";
		$view_register_master->RegisterTotal->CssClass = "";
		$view_register_master->RegisterTotal->ViewCustomAttributes = "";

		// Short_Over
		$view_register_master->Short_Over->ViewValue = $view_register_master->Short_Over->CurrentValue;
		$view_register_master->Short_Over->ViewValue = ew_FormatNumber($view_register_master->Short_Over->ViewValue, 2, -1, -1, -2);
		$view_register_master->Short_Over->CssStyle = "font-weight:bold;";
		$view_register_master->Short_Over->CssClass = "";
		$view_register_master->Short_Over->ViewCustomAttributes = "";

		// MonthYear
		$view_register_master->MonthYear->HrefValue = "";

		// ID
		$view_register_master->ID->HrefValue = "";

		// PreviousID
		$view_register_master->PreviousID->HrefValue = "";

		// LogDate
		$view_register_master->LogDate->HrefValue = "";

		// PrevLogDate
		$view_register_master->PrevLogDate->HrefValue = "";

		// Link
		if (!is_null($view_register_master->ID->CurrentValue)) {
			$view_register_master->Link->HrefValue = $view_register_master->ID->CurrentValue;
			if ($view_register_master->Export <> "") $view_register_master->Link->HrefValue = ew_ConvertFullUrl($view_register_master->Link->HrefValue);
		} else {
			$view_register_master->Link->HrefValue = "";
		}

		// XReading
		$view_register_master->XReading->HrefValue = "";

		// YesterdayXReading
		$view_register_master->YesterdayXReading->HrefValue = "";

		// DiffXreading
		$view_register_master->DiffXreading->HrefValue = "";

		// CheckAmount
		$view_register_master->CheckAmount->HrefValue = "";

		// LunchAmount
		$view_register_master->LunchAmount->HrefValue = "";

		// OverAmount
		$view_register_master->OverAmount->HrefValue = "";

		// CreditAmount
		$view_register_master->CreditAmount->HrefValue = "";

		// PayoutAmount
		$view_register_master->PayoutAmount->HrefValue = "";

		// TotalDrawAmount
		$view_register_master->TotalDrawAmount->HrefValue = "";

		// PreviousDrawAmount
		$view_register_master->PreviousDrawAmount->HrefValue = "";

		// CashDiff
		$view_register_master->CashDiff->HrefValue = "";

		// CashAdj
		$view_register_master->CashAdj->HrefValue = "";

		// OtherAdj
		$view_register_master->OtherAdj->HrefValue = "";

		// RegisterTotal
		$view_register_master->RegisterTotal->HrefValue = "";

		// Short_Over
		$view_register_master->Short_Over->HrefValue = "";
	} elseif ($view_register_master->RowType == EW_ROWTYPE_ADD) { // Add row
	} elseif ($view_register_master->RowType == EW_ROWTYPE_EDIT) { // Edit row
	} elseif ($view_register_master->RowType == EW_ROWTYPE_SEARCH) { // Search row
	}

	// Call Row Rendered event
	$view_register_master->Row_Rendered();
}
?>
<?php

// Export data in Xml or Csv format
function ExportData() {
	global $nTotalRecs, $nStartRec, $nStopRec, $nTotalRecs, $nDisplayRecs, $view_register_master;
	$sCsvStr = "";
	$rs = LoadRecordset();
	$nTotalRecs = $rs->RecordCount();
	$nStartRec = 1;

	// Export all
	if (defined("EW_EXPORT_ALL")) {
		$nStopRec = $nTotalRecs;
	} else { // Export 1 page only
		SetUpStartRec(); // Set Up Start Record Position

		// Set the last record to display
		if ($nDisplayRecs < 0) {
			$nStopRec = $nTotalRecs;
		} else {
			$nStopRec = $nStartRec + $nDisplayRecs - 1;
		}
	}
	if ($view_register_master->Export == "csv") {
		$sCsvStr .= "MonthYear" . ",";
		$sCsvStr .= "ID" . ",";
		$sCsvStr .= "PreviousID" . ",";
		$sCsvStr .= "LogDate" . ",";
		$sCsvStr .= "PrevLogDate" . ",";
		$sCsvStr .= "Link" . ",";
		$sCsvStr .= "XReading" . ",";
		$sCsvStr .= "YesterdayXReading" . ",";
		$sCsvStr .= "DiffXreading" . ",";
		$sCsvStr .= "CheckAmount" . ",";
		$sCsvStr .= "LunchAmount" . ",";
		$sCsvStr .= "OverAmount" . ",";
		$sCsvStr .= "CreditAmount" . ",";
		$sCsvStr .= "PayoutAmount" . ",";
		$sCsvStr .= "TotalDrawAmount" . ",";
		$sCsvStr .= "PreviousDrawAmount" . ",";
		$sCsvStr .= "CashDiff" . ",";
		$sCsvStr .= "CashAdj" . ",";
		$sCsvStr .= "OtherAdj" . ",";
		$sCsvStr .= "RegisterTotal" . ",";
		$sCsvStr .= "Short_Over" . ",";
		$sCsvStr = substr($sCsvStr, 0, strlen($sCsvStr)-1); // Remove last comma
		$sCsvStr .= "\n";
	}

	// Move to first record directly for performance reason
	$nRecCount = $nStartRec - 1;
	if (!$rs->EOF) {
		$rs->MoveFirst();
		$rs->Move($nStartRec - 1);
	}
	while (!$rs->EOF && $nRecCount < $nStopRec) {
		$nRecCount++;
		if (intval($nRecCount) >= intval($nStartRec)) {
			LoadRowValues($rs);
			if ($view_register_master->Export == "csv") {
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_register_master->MonthYear->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_register_master->ID->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_register_master->PreviousID->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_register_master->LogDate->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_register_master->PrevLogDate->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_register_master->Link->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_register_master->XReading->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_register_master->YesterdayXReading->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_register_master->DiffXreading->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_register_master->CheckAmount->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_register_master->LunchAmount->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_register_master->OverAmount->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_register_master->CreditAmount->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_register_master->PayoutAmount->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_register_master->TotalDrawAmount->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_register_master->PreviousDrawAmount->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_register_master->CashDiff->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_register_master->CashAdj->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_register_master->OtherAdj->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_register_master->RegisterTotal->CurrentValue)) . '",';
				$sCsvStr .= '"' . str_replace('"', '""', strval($view_register_master->Short_Over->CurrentValue)) . '",';
				$sCsvStr = substr($sCsvStr, 0, strlen($sCsvStr)-1); // Remove last comma
				$sCsvStr .= "\n";
			}
		}
		$rs->MoveNext();
	}

	// Close recordset
	$rs->Close();
	if ($view_register_master->Export == "csv") {
		echo $sCsvStr;
	}
}
?>
<?php

// Page Load event
function Page_Load() {

	//echo "Page Load";
}

// Page Unload event
function Page_Unload() {

	//echo "Page Unload";
}
?>
